Imports System.Configuration

Public Class frmITAdminMain
    Inherits System.Windows.Forms.Form
    Public LogFlag As Integer
    Public ImagePath As String = ConfigurationManager.AppSettings("ImagePath")
    Public MainTitle As String
    Dim ProdForm As New frmUsers
    Dim GrpForm As New frmARgroups
    Dim ComForm As New frmCompanyView
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
    Friend WithEvents AdministrationToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents CompanyNewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents CompanyViewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents StoreWarehouseToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents StoreWarehouseCreateToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents StoreWarehouseViewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents UsersToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents UsersViewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents DatabaseSecurityToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents DatabaseBackupToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Dim DptForm As New frmDepartmentView
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ttPosMenu As System.Windows.Forms.ToolTip
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents btnUser As System.Windows.Forms.Button
    Friend WithEvents btnCompany As System.Windows.Forms.Button
    Friend WithEvents btnSalesman As System.Windows.Forms.Button
    Friend WithEvents BtnDpt As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmITAdminMain))
        Me.ttPosMenu = New System.Windows.Forms.ToolTip(Me.components)
        Me.Button1 = New System.Windows.Forms.Button()
        Me.btnUser = New System.Windows.Forms.Button()
        Me.btnCompany = New System.Windows.Forms.Button()
        Me.BtnDpt = New System.Windows.Forms.Button()
        Me.btnSalesman = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
        Me.AdministrationToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.CompanyNewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.CompanyViewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.StoreWarehouseToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.StoreWarehouseCreateToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.StoreWarehouseViewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.UsersToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.UsersViewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.DatabaseSecurityToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.DatabaseBackupToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
        Me.Panel1.SuspendLayout()
        Me.MenuStrip1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button1.Image = CType(resources.GetObject("Button1.Image"), System.Drawing.Image)
        Me.Button1.Location = New System.Drawing.Point(323, 73)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(28, 24)
        Me.Button1.TabIndex = 67
        Me.ttPosMenu.SetToolTip(Me.Button1, "Logoff/Logon")
        Me.Button1.Visible = False
        '
        'btnUser
        '
        Me.btnUser.Image = CType(resources.GetObject("btnUser.Image"), System.Drawing.Image)
        Me.btnUser.Location = New System.Drawing.Point(288, 73)
        Me.btnUser.Name = "btnUser"
        Me.btnUser.Size = New System.Drawing.Size(29, 24)
        Me.btnUser.TabIndex = 71
        Me.ttPosMenu.SetToolTip(Me.btnUser, "User Details")
        Me.btnUser.Visible = False
        '
        'btnCompany
        '
        Me.btnCompany.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnCompany.Image = CType(resources.GetObject("btnCompany.Image"), System.Drawing.Image)
        Me.btnCompany.Location = New System.Drawing.Point(60, 73)
        Me.btnCompany.Name = "btnCompany"
        Me.btnCompany.Size = New System.Drawing.Size(28, 24)
        Me.btnCompany.TabIndex = 74
        Me.ttPosMenu.SetToolTip(Me.btnCompany, "Company Setup")
        Me.btnCompany.Visible = False
        '
        'BtnDpt
        '
        Me.BtnDpt.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.BtnDpt.Image = CType(resources.GetObject("BtnDpt.Image"), System.Drawing.Image)
        Me.BtnDpt.Location = New System.Drawing.Point(94, 73)
        Me.BtnDpt.Name = "BtnDpt"
        Me.BtnDpt.Size = New System.Drawing.Size(28, 24)
        Me.BtnDpt.TabIndex = 75
        Me.ttPosMenu.SetToolTip(Me.BtnDpt, "Showroom/Warehouse")
        Me.BtnDpt.Visible = False
        '
        'btnSalesman
        '
        Me.btnSalesman.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnSalesman.Image = CType(resources.GetObject("btnSalesman.Image"), System.Drawing.Image)
        Me.btnSalesman.Location = New System.Drawing.Point(128, 73)
        Me.btnSalesman.Name = "btnSalesman"
        Me.btnSalesman.Size = New System.Drawing.Size(28, 24)
        Me.btnSalesman.TabIndex = 77
        Me.ttPosMenu.SetToolTip(Me.btnSalesman, "Salesman Setup")
        Me.btnSalesman.Visible = False
        '
        'Button2
        '
        Me.Button2.BackgroundImage = CType(resources.GetObject("Button2.BackgroundImage"), System.Drawing.Image)
        Me.Button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button2.Location = New System.Drawing.Point(162, 73)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(28, 24)
        Me.Button2.TabIndex = 79
        Me.ttPosMenu.SetToolTip(Me.Button2, "Create TXT file for PDA")
        Me.Button2.Visible = False
        '
        'Panel1
        '
        Me.Panel1.BackColor = System.Drawing.Color.SlateGray
        Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel1.Controls.Add(Me.Button1)
        Me.Panel1.Controls.Add(Me.Button2)
        Me.Panel1.Controls.Add(Me.btnSalesman)
        Me.Panel1.Controls.Add(Me.btnCompany)
        Me.Panel1.Controls.Add(Me.btnUser)
        Me.Panel1.Controls.Add(Me.BtnDpt)
        Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Panel1.Location = New System.Drawing.Point(0, 26)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(825, 524)
        Me.Panel1.TabIndex = 63
        '
        'MenuStrip1
        '
        Me.MenuStrip1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AdministrationToolStripMenuItem, Me.UsersToolStripMenuItem, Me.DatabaseSecurityToolStripMenuItem})
        Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
        Me.MenuStrip1.Name = "MenuStrip1"
        Me.MenuStrip1.Size = New System.Drawing.Size(825, 26)
        Me.MenuStrip1.TabIndex = 83
        Me.MenuStrip1.Text = "MenuStrip1"
        '
        'AdministrationToolStripMenuItem
        '
        Me.AdministrationToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.CompanyNewToolStripMenuItem, Me.CompanyViewToolStripMenuItem, Me.StoreWarehouseToolStripMenuItem})
        Me.AdministrationToolStripMenuItem.Name = "AdministrationToolStripMenuItem"
        Me.AdministrationToolStripMenuItem.Size = New System.Drawing.Size(112, 22)
        Me.AdministrationToolStripMenuItem.Text = "Administration"
        '
        'CompanyNewToolStripMenuItem
        '
        Me.CompanyNewToolStripMenuItem.Name = "CompanyNewToolStripMenuItem"
        Me.CompanyNewToolStripMenuItem.Size = New System.Drawing.Size(185, 22)
        Me.CompanyNewToolStripMenuItem.Text = "Company - New"
        '
        'CompanyViewToolStripMenuItem
        '
        Me.CompanyViewToolStripMenuItem.Name = "CompanyViewToolStripMenuItem"
        Me.CompanyViewToolStripMenuItem.Size = New System.Drawing.Size(185, 22)
        Me.CompanyViewToolStripMenuItem.Text = "Company -View"
        '
        'StoreWarehouseToolStripMenuItem
        '
        Me.StoreWarehouseToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.StoreWarehouseCreateToolStripMenuItem, Me.StoreWarehouseViewToolStripMenuItem})
        Me.StoreWarehouseToolStripMenuItem.Name = "StoreWarehouseToolStripMenuItem"
        Me.StoreWarehouseToolStripMenuItem.Size = New System.Drawing.Size(185, 22)
        Me.StoreWarehouseToolStripMenuItem.Text = "Store/Warehouse"
        '
        'StoreWarehouseCreateToolStripMenuItem
        '
        Me.StoreWarehouseCreateToolStripMenuItem.Name = "StoreWarehouseCreateToolStripMenuItem"
        Me.StoreWarehouseCreateToolStripMenuItem.Size = New System.Drawing.Size(237, 22)
        Me.StoreWarehouseCreateToolStripMenuItem.Text = "Store/Warehouse - Create"
        '
        'StoreWarehouseViewToolStripMenuItem
        '
        Me.StoreWarehouseViewToolStripMenuItem.Name = "StoreWarehouseViewToolStripMenuItem"
        Me.StoreWarehouseViewToolStripMenuItem.Size = New System.Drawing.Size(237, 22)
        Me.StoreWarehouseViewToolStripMenuItem.Text = "Store/Warehouse - View"
        '
        'UsersToolStripMenuItem
        '
        Me.UsersToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.UsersViewToolStripMenuItem})
        Me.UsersToolStripMenuItem.Name = "UsersToolStripMenuItem"
        Me.UsersToolStripMenuItem.Size = New System.Drawing.Size(54, 22)
        Me.UsersToolStripMenuItem.Text = "Users"
        '
        'UsersViewToolStripMenuItem
        '
        Me.UsersViewToolStripMenuItem.Name = "UsersViewToolStripMenuItem"
        Me.UsersViewToolStripMenuItem.Size = New System.Drawing.Size(110, 22)
        Me.UsersViewToolStripMenuItem.Text = "Users"
        '
        'DatabaseSecurityToolStripMenuItem
        '
        Me.DatabaseSecurityToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DatabaseBackupToolStripMenuItem})
        Me.DatabaseSecurityToolStripMenuItem.Name = "DatabaseSecurityToolStripMenuItem"
        Me.DatabaseSecurityToolStripMenuItem.Size = New System.Drawing.Size(130, 22)
        Me.DatabaseSecurityToolStripMenuItem.Text = "Database Security"
        '
        'DatabaseBackupToolStripMenuItem
        '
        Me.DatabaseBackupToolStripMenuItem.Name = "DatabaseBackupToolStripMenuItem"
        Me.DatabaseBackupToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
        Me.DatabaseBackupToolStripMenuItem.Text = "Database Backup"
        '
        'frmITAdminMain
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(825, 550)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.MenuStrip1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.IsMdiContainer = True
        Me.MainMenuStrip = Me.MenuStrip1
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmITAdminMain"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "System Administration"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.Panel1.ResumeLayout(False)
        Me.MenuStrip1.ResumeLayout(False)
        Me.MenuStrip1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region
    Private Sub PosMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ValidUser = True
        LogFlag = 1
        ProdForm.MdiParent = Me
        GrpForm.MdiParent = Me
        ComForm.MdiParent = Me
        DptForm.MdiParent = Me

        If ValidUser = True Then
            frmITAdminMain.ActiveForm.Text = frmITAdminMain.ActiveForm.Text + " (User:" & UserName & "/" + CompanyTitle + "-" + LoginYear + ")"
            btnCompany.PerformClick()
        Else
            btnUser.Enabled = False
        End If
    End Sub
    Private Sub btnAccess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'Panel1.Controls.Clear()
        'tbTitle.Text = "USER GROUPS ACCESS LIST"
        'If EmlForm Is Nothing Then
        '    EmlForm = New ARcusProdMatrix
        'End If

        'Panel1.Controls.Add(EmlForm)
        'EmlForm.Show()
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If LogFlag = 1 Then
            If MsgBox("You will be logged off from SERPS." + vbLf + "Click again to logon", MsgBoxStyle.YesNo, "Inventory Manager") = MsgBoxResult.Yes Then
                Button1.Image = Button1.Image.FromFile(ImagePath + "green1.ico")
                LogFlag = 2
                If Panel1.Controls.Count > 0 Then
                    Panel1.Controls.Item(0).Enabled = False

                End If

                btnUser.Enabled = False

            End If
        Else
            MsgBox("You are loged in to Inventory Manager" + vbLf + "Click again to logoff", MsgBoxStyle.Information, "Inventory Manager")
            Button1.Image = Image.FromFile(ImagePath + "red.ico")
            LogFlag = 1
            If Panel1.Controls.Count > 0 Then
                Panel1.Controls.Item(0).Enabled = True

            Else
            End If

        End If
    End Sub


    Dim addComp As frmCompanyAdd
    Dim viewComp As frmCompanyView

    Private Sub CompanyNewToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyNewToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 48) = True Then
            addComp = New frmCompanyAdd
            addComp.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If

    End Sub

    Dim addDept As frmDepartmentAdd
    Dim viewDept As frmDepartmentView

    Private Sub CompanyViewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyViewToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 50) = True Then
            viewComp = New frmCompanyView
            viewComp.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
    End Sub


    Private Sub StoreWarehouseCreateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StoreWarehouseCreateToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 51) = True Then
            addDept = New frmDepartmentAdd
            addDept.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
    End Sub

    Private Sub StoreWarehouseViewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StoreWarehouseViewToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 53) = True Then
            viewDept = New frmDepartmentView
            viewDept.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If
    End Sub

    Dim usr As frmUsers

    Private Sub UsersViewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsersViewToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 54) = True Then
            usr = New frmUsers
            usr.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If

    End Sub

    Dim backup As frmDBBackUp
    Private Sub DatabaseBackupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DatabaseBackupToolStripMenuItem.Click
        Dim ApData As New APdataLogic
        If ApData.IsValidUserOption(UserID, CompanyID, 70) = True Then
            backup = New frmDBBackUp
            backup.ShowDialog()
        Else
            MsgBox("Access Denied !", MsgBoxStyle.Critical, "Inventory Manager")
        End If

    End Sub
 
End Class
